home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Str / c / DecodeHex next >
Text File  |  1995-07-08  |  1KB  |  33 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Str.DecodeHex.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (06 Mar 1994)
  14.     Purpose: Convert a hex digit character to a number.
  15. */
  16.  
  17. #include <ctype.h>
  18.  
  19. #include "DeskLib:Str.h"
  20.  
  21.  
  22. int Str_DecodeHex(char digit)
  23. {
  24.   digit = toupper(digit);
  25.  
  26.   if ((digit >= '0') && (digit <= '9'))
  27.     return (int) (digit - '0');
  28.   else if ((digit >= 'A') && (digit <= 'F'))
  29.     return (int) ((digit - 'A') + 10);
  30.   else return -1;
  31. }
  32.  
  33.